#!/bin/bash
#
# This file should be added to the .git/hooks repository
# 

lof=$(git diff --cached --name-only --diff-filter=ACM)  
#echo $lof
for fic in $lof
do
if [[ "$fic" == *".F" ]]; then
        if cmp --silent -- <(head -n 22 scripts/copyright/f_COPYRIGHT.txt) <(head -n 22 ${fic}) 
        then
                echo $fic "copyright ok"
        else
                echo $fic "copyright update "
                cp $fic ${fic}.backup
                sed -i "/Copyright>/d" ${fic}
                cat scripts/copyright/f_COPYRIGHT.txt ${fic} > pre_commit.tmp
                mv pre_commit.tmp ${fic}
                git add ${fic}
                rm ${fic}.backup
        fi
fi
done
exit 0

